package com.tf.six.controller;

// ReportController.java

import com.tf.six.entity.Report;
import com.tf.six.service.ReportService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/report")
@Tag(name = "举报管理", description = "处理商品/评论举报相关操作")
public class ReportController {

    @Autowired
    private ReportService reportService;

    @PostMapping
    @Operation(summary = "提交举报")
    public boolean submitReport(@RequestBody Report report) {
        return reportService.save(report);
    }

    @GetMapping("/{id}")
    @Operation(summary = "获取举报详情")
    public Report getReport(@PathVariable Long id) {
        return reportService.getById(id);
    }

    @PutMapping("/handle/{id}")
    @Operation(summary = "处理举报")
    public boolean handleReport(@PathVariable Long id) {
        Report report = reportService.getById(id);
        report.setStatus(1);
        return reportService.updateById(report);
    }
}